home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE3 / POWERBASE / DOCS / Ch10-Utils < prev    next >
Text File  |  2001-10-29  |  10KB  |  171 lines

  1. =================
  2. Ch 10 − Utilities
  3. =================
  4.  
  5. All the procedures described in this chapter will be found on the Utilities
  6. submenu of the iconbar menu, enabling you to examine and alter the structure
  7. of an existing database. Note that, if passwords have been set, you need to
  8. enter the database with the “Manager” level password to obtain access to
  9. this submenu. 
  10.  
  11. 10.1    Changing the Primary Key
  12. --------------------------------
  13. The primary key of a database is determined when it is created but is not
  14. fixed for all time. The New primary key choice displays the same dialogue
  15. box as was used for creating the primary key in the first place, but with
  16. the addition of two radio buttons, whose function is described below. The
  17. present key structure is shown. Simply alter it to what you require and
  18. click on Create or type Return.
  19.  
  20. The first of the two radio buttons (Retain subfile structure) is selected by
  21. default, making the records appear in the same subfiles as before. Any
  22. subsidiary indices, therefore, will still be valid. If you deselect this
  23. radio button with ADJUST (i.e. have neither button selected) then all the
  24. records will be placed in the currently selected subfile and you will need
  25. to rebuild your subsidiary indices.
  26.  
  27. Selecting the second button (Restore deleted records) also places the
  28. records in the current subfile, but has the additional effect of recovering
  29. “deleted” records, i.e. records which are still lurking in the Database file
  30. but aren’t in the primary key index. You would need to use this option when
  31. the primary key index is lost or corrupted. If the PrimaryKey file is
  32. actually missing both radio buttons are shaded in order to enforce this
  33. mode. Note that you cannot recover deleted records if the Blank record on
  34. deletion switch is set in the Preferences window: the data has really gone
  35. for good in this case.
  36.  
  37. 10.2    Adjusting the record format
  38. -----------------------------------
  39. Minor changes can be made without rebuilding the database. Choose Adjust
  40. format and the blank record window with the blue grid will be displayed. 
  41. Clicking MENU over this  brings up the same menu as you used to create the
  42. screen originally, but the Field definition window has some options shaded.
  43. Thus you can’t delete fields, add new ones or alter the data lengths, but
  44. you can re-position fields, change descriptors and tags, and alter the
  45. visible lengths of data fields. You can also change the field type within
  46. its class, e.g. an Alphanumeric field could be changed to a Numeric one
  47. since both belong to the Editable class, or you could change a 2-state
  48. Check-box to a 3-state one, but you couldn’t change either into a Calculated
  49. field. When you have finished making the changes choose Quit design from the
  50. menu.
  51.  
  52. 10.3    Changing the record format
  53. ----------------------------------
  54. This is more drastic, but it is not always possible to foresee future needs
  55. and you may have to introduce a new field or lengthen an existing one. That
  56. involves rebuilding the whole database. Powerbase actually builds a
  57. completely new database under another name, leaving your original database
  58. unchanged in case anything goes wrong, so make sure you have enough disc
  59. space available.  Choose New record format.  The Reformat database window
  60. will appear.  Several options are now available:
  61.  
  62. •       Enter the new database name and drag the database sprite to a filer
  63.         window. You will then be offered the record layout for editing, as
  64.         when creating a new database.  Make the required modifications then
  65.         choose Quit design from the menu.
  66.  
  67. •       If you already have a Form file in the new format drop it onto the
  68.         Reformat window where its name will appear. Enter the new database
  69.         name and drag the sprite to a filer window.
  70.  
  71. •       Create a new database shell (which must have a different name from
  72.         the one to be reformatted) and copy your existing Form file into it. 
  73.         Open this “database”, edit the layout and save the Form file.  Open
  74.         the old database, call up the Reformat window and drop the new one
  75.         onto it. Its pathname will appear in the window. Finally click on
  76.         Reformat. This was the method used in versions of Powerbase prior to
  77.         7.52 and, although it still works with the latest version, it should
  78.         be regarded as obsolete.
  79.  
  80. Data from a field in the old database will be copied to a field in the new
  81. one with the same tag. The new database must therefore retain the same tags
  82. as the old for data which is to be common to both. A tag present in the old
  83. database but not in the new is assumed to refer to a deleted field and the
  84. associated data is not transferred.  A field present in both databases but
  85. with a shorter defined length in the new one will have its data truncated if
  86.  
  87.                                 - 50 -
  88.  
  89. necessary. A tag present in the new database but not in the old is assumed
  90. to be a new field and will be left blank. Before proceeding Powerbase will
  91. inform you of any likely data loss due to deleted or shortened fields and
  92. ask you if you wish to proceed. When the process is complete you will be
  93. left with the new database open. Links to validation tables, calculation
  94. formulae, and indices are preserved unless a relevant field was omitted from
  95. the new record.
  96.  
  97. 10.4    Merging two databases
  98. -----------------------------
  99. Two databases may be merged provided they have identical record structures.
  100. With the first database open, select Merge database and drag the second
  101. database to the displayed window. The pathnames of both databases can now be
  102. seen. The pathname of the open database is duplicated in a writable icon
  103. labelled Save as. If you accept this default the data from the second
  104. database will be merged into the open one. You can, however, change this
  105. name and drag the database icon to a directory window. The merged data will
  106. then go into a completely new database leaving both source databases as they
  107. were. When you click on Merge databases Powerbase will check that the two
  108. record formats are identical and report an error if they aren’t.  An option
  109. switch determines the action taken with regard to Sequence number fields
  110. (see 8.4.1).
  111.  
  112. Two radio buttons are also present, as in the dialogue box for rebuilding
  113. the primary key, and their functions are essentially the same (see 10.1).
  114. Having the first button selected merges records into the same subfiles as
  115. those they occupied in the second database. Having neither selected merges
  116. records into the current subfile of the first database, regardless of where
  117. they are in the second database. Having the second button selected does the
  118. same, but also imports records which were “deleted” in the second database.  
  119.  
  120. 10.5    Changing the Database Length
  121. ------------------------------------
  122. The number of available records in a database may be increased or decreased.
  123. Change length leads to a window with two writable icons. The first specifies
  124. the new database length, the other  determines the number of records by
  125. which the database will be lengthened each time it becomes full. If this
  126. value is zero no automatic lengthening occurs; a warning is displayed
  127. instead.  You will only be allowed to shorten a database if the surplus
  128. records have never been used or have been blanked on deletion.  Otherwise
  129. you can only get rid of them by exporting all the current records as a
  130. subset (see 13.2)
  131.  
  132. 10.6    Inspecting and balancing index trees
  133. --------------------------------------------
  134. Print index lets you examine the structure of the current index to find out
  135. how many keys are present in each level. The ideal numbers in a
  136. perfectly-balanced index tree are 1, 2, 4, 8, 16, 32, 64, 128 etc. (i.e.
  137. powers of 2, beginning with 20.) A submenu gives you the option of printing
  138. the actual keys, positioned according to the level they occupy in the tree,
  139. or printing only the total number of nodes in each level. 
  140.  
  141. The data printed is for all subfiles of the current key, but there is an
  142. option to restrict it to the current subfile. There are also two
  143. alternatives for the layout of the complete tree. Output is to a screen
  144. window from which it may be saved in the same way as any other report. (If
  145. you have printed the keys themselves then double-clicking with SELECT on any
  146. key will call up the associated database record.)
  147.  
  148. If the tree is very unbalanced and, especially, if there is an enormous
  149. number of levels with only 1 or 2 keys in each, you are advised to balance
  150. it using the Balance index choice*. It is also possible to make Powerbase
  151. balance the index automatically at regular intervals. To turn on
  152. auto-balancing choose Preferences  from the iconbar menu.  Select the
  153. Balance every <n> records switch, placing your chosen value of n in the
  154. writable icon provided, then click on Accept.
  155.  
  156. Auto-balancing is most likely to be useful when a large number of records
  157. are being entered in primary-key order.  This will happen if you are
  158. entering data from a lot of forms in alphabetical order of name where name
  159. is the primary key.  It is also very likely to happen when importing CSV
  160. files as these are often ordered according to the data item which becomes
  161. the primary key field of the database record.
  162.  
  163. 10.7    Finding duplicate primary keys
  164. --------------------------------------
  165. Wherever possible a primary key should be chosen so as to be unique. Where
  166. duplication of the primary key might occur the designer of the database can
  167. decide either to allow or forbid it (see 11.2.1). If duplicate keys are
  168. permitted it is sometimes useful to have a list of them. Such a list is
  169. created by Find duplicates and may be saved as a text file.
  170.  
  171.                                 - 51 -